<template>
  <van-cell
    class="article-item"
    :to="{ name: 'article', params: { articleId: article.art_id } }"
  >
    <div slot="title" class="title van-multi-ellipsis--l3">
      {{ article.title }}
    </div>

    <div slot="label">
      <div class="cover-wrap" v-if="article.cover.type === 3">
        <van-image
          fit="cover"
          v-for="(img, index) in article.cover.images"
          :key="index"
          :src="img"
        />
      </div>

      <div class="label-wrap">
        <span>{{ article.aut_name }}</span>
        <span>{{ article.comm_count }}评论</span>
        <span>{{ article.pubdate | relativeTime }}</span>
      </div>
    </div>

    <div class="label-wrap" slot="default" v-if="article.cover.type === 1">
      <van-image :src="article.cover.images[0]" />
    </div>
  </van-cell>
</template>

<script>
export default {
  name: "ArticleItem",
  props: {
    article: {
      type: Object,
      required: true,
    },
  },
};
</script>

<style scoped lang="less">
.article-item {
  .title {
    font-size: 16px;
    color: #3a3a3a;
  }

  .van-cell__value {
    flex: unset;
    width: 116px;
    height: 73px;
    margin-left: 12px;

    /deep/.van-image__img {
      width: 116px;
      height: 73px;
    }
  }

  .cover-wrap {
    display: flex;
    height: 73px;
    padding: 11px 0 15px 0;
    .van-image {
      flex: 1;
      &:not(:last-child) {
        padding-right: 4px;
      }
    }
  }

  .label-wrap {
    font-size: 11px;
    color: #b4b4b4;

    span {
      margin-right: 12px;
    }
  }
}
</style>
